package com.design.proxy.dbroute;

import com.design.proxy.dbroute.proxy.OrderServiceDynamicProxy;

import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 切面编程动态切换数据源
 * @Author:         cong zhi
 * @CreateDate:     2021/3/23 20:54
 * @UpdateUser:     cong zhi
 * @UpdateDate:     2021/3/23 20:54
 * @UpdateRemark:   修改内容
 * @Version:        1.0
 */
public class DBRouteProxyTets {

    public static void main(String[] args) {
        try {
            Order order =new Order();
            order.setCreateTime(System.currentTimeMillis());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
            Date date = sdf.parse("2021/03/23");
            order.setCreateTime(date.getTime());
            IOrderService orderService =(IOrderService) new OrderServiceDynamicProxy().getInstance(new OrderService());
//            IOrderService orderService = new OrderServiceStaticProxy(new OrderService());
            orderService.createOrder(order);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
